{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-body">
        <form action="{:request()->url()}" class="layui-form" method="post">
            <div class="layui-form-item">
                <label class="layui-form-label">上级栏目</label>
                <div class="layui-input-inline" style="width: 200px">
                    <select name="pid">
                        <option value="0">一级栏目</option>
                        {foreach name="pid" item="v"}
                        <option value="{$v.id}" {if condition="isset($data) and $data.pid eq $v.id or input('pid') eq $v.id"}selected="selected"{/if}>{neq name="v.level" value="1"}|{php}for($i=1;$i<$v['level'];$i++){echo ' ----';}{/php}{/neq} {$v.name}</option>
                        {/foreach}
                    </select>
                </div>
                <label class="layui-form-label">模型类型</label>
                <div class="layui-input-inline" style="width: 200px">
                    <select name="model" lay-filter="model">
                        <option value="">请选择模型</option>
                        {foreach name=":get_dict_list(1)" item="d"}
                        <option value="{$d.id}" {if condition="isset($data) and $data.model eq $d.id"}selected="selected"{/if}>{$d.name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">分类名称</label>
                <div class="layui-input-inline" style="width: 200px">
                    <input type="text" name="name" value="{$data.name|default=''}" autocomplete="off" placeholder="" lay-verify="required" class="layui-input">
                </div>
                <label class="layui-form-label">分类目录</label>
                <div class="layui-input-inline" style="width: 200px">
                    <input type="text" name="name_en" value="{$data.name_en|default=''}" autocomplete="off" placeholder="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">分类图片</label>
                <div class="layui-input-block">
                    {:get_field('image',isset($data.image)?$data.image:'','image','image')}
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">页面模板</label>
                <div class="layui-input-block">
                    <input type="text" name="template" value="{$data.template|default='lists'}" autocomplete="off" placeholder="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">META关键词</label>
                <div class="layui-input-block">
                    <textarea name="keywords" class="layui-textarea" placeholder="">{$data.keywords|default=''}</textarea>
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">META描述</label>
                <div class="layui-input-block">
                    <textarea name="description" class="layui-textarea">{$data.description|default=''}</textarea>
                </div>
            </div>

            <div class="layui-form-item layui-form-text" id="wxapp_url">
                <label class="layui-form-label">跳转链接</label>
                <div class="layui-input-block">
                    <input type="text" name="url" value="{$data.url|default='https://'}" autocomplete="off" placeholder="请输入跳转链接" class="layui-input">
                </div>
            </div>
            
            <div class="layui-form-item">
                <div class="layui-input-block">
                    {:token_field()}
                    <button class="layui-btn" lay-filter="i" lay-submit="">保存</button>
                    <button class="layui-btn layui-btn-primary" type="reset">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>
{/block}
{block name="js"}
<script>
    {if isset($data.model) and $data.model == '5'}
        $('#wxapp_url').show();
    {else}
        $('#wxapp_url').hide();
    {/if}
    form.on('select(model)', function(data){
        var id = data.value;
        //如果是跳转链接
        if(id == 5){
            $('#wxapp_url').show();
        }else{
            $('#wxapp_url').hide();
        }
    });
</script>
{/block}